﻿using System;

namespace iTPS.Service.Core
{
    public class Fixed
    {
        public const int ZeusSuccess = 200;

        public const int MQSuccess = 200;

        private static DateTime _doomsDay;

        /// <summary>
        /// 末日时间
        /// </summary>
        public static DateTime DoomsDay {
            get {
                if (_doomsDay == null || _doomsDay.Ticks == 0)
                {
                    _doomsDay = new DateTime(1970, 1, 1);
                }
                return _doomsDay;
            }
        }

        #region 验证正则
        /// <summary>
        /// 手机号码的正确性
        /// </summary>
        /// <param name="strHandSet"></param>
        /// <returns></returns>
        public static bool IsHandset(string strHandSet)
        {
            return System.Text.RegularExpressions.Regex.IsMatch(strHandSet, @"^[1]\d{10}$");
        }

        /// <summary>
        /// 邮箱的正确性
        /// </summary>
        /// <param name="strEmail"></param>
        /// <returns></returns>
        public static bool IsEmail(string strEmail)
        {
            return System.Text.RegularExpressions.Regex.IsMatch(strEmail, @"\w{1,}@\w{1,}\.\w{1,}");
        }

        /// <summary>
        /// 用户名验证
        /// </summary>
        /// <param name="strUserName"></param>
        /// <returns></returns>
        public static bool IsUserName(string strUserName)
        {
            return System.Text.RegularExpressions.Regex.IsMatch(strUserName, @"^[a-zA-Z]{1}([a-zA-Z0-9]|[._]){5,19}$");
        }

        /// <summary>
        /// 密码验证
        /// </summary>
        /// <param name="str_Password"></param>
        /// <returns></returns>
        public static bool IsPassword(string str_Password)
        {
            return System.Text.RegularExpressions.Regex.IsMatch(str_Password, @"^[0-9a-zA-Z`~!@#$%\^&*()_+-={}|\[\]:"";'<>?,.]{6,20}$");
        }

        /// <summary>
        /// 获取时间戳
        /// </summary>
        /// <returns></returns>
        public static string GenerateTimeStamp()
        {
            return Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds).ToString();
        }

        #endregion
    }
}
